<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="Number" content="">
<title>品牌{$tit}</title>
{include file="head"}
<link href="/static/thinkct/css/basic.css?v=1" rel="stylesheet" type="text/css" /><script language="javascript" src="/static/thinkct/js/jquery.m.js"></script><script language="javascript" src="/static/thinkct/js/layui/layui.js"></script><script language="javascript" src="/static/thinkct/js/common.js?v=1"></script><script language="javascript" src="/static/thinkct/js/member.js?v=1"></script><link href="/static/thinkct/css/member.css?v=1" rel="stylesheet" type="text/css" /><link href="/static/thinkct/js/layui/css/layui.css" rel="stylesheet" type="text/css" /><script language="javascript" src="/static/thinkct/js/plupload.js"></script><script language="javascript" src="/static/thinkct/js/upload.js"></script><script language="javascript" src="/static/thinkct/editor/js/wangEditor.min.js"></script><link href="/static/thinkct/editor/css/wangEditor.min.css" rel="stylesheet" type="text/css" /></head>
<body>
{include file="uhead"}

<div class='umain' style='box-shadow:0 1px 5px rgba(0,0,0,.05);'>
<div class="flow-step" id='amount3'>           	
		<li data='form'>
			<span class="num"><em></em><i>1</i></span>                	
			<span class="line_bg lbg-r"></span>
			<p>填写品牌信息</p>
			<cite></cite>
		</li>
		<li data='audit'>
			<span class="num"><em></em><i>2</i></span>
			<span class="line_bg lbg-l"></span>
			<span class="line_bg lbg-r"></span>
			<p>{:sysconf('site_name')}官方审核</p>
		</li>
		<li data='info'>
			<span class="num"><em></em><i>3</i></span>
			<span class="line_bg lbg-l"></span>
			<p>品牌开始展示</p>
			<cite></cite>
		</li>
</div>

<form class="layui-form layui-font14" style='padding-top:15px;' name="" action="" method="post" enctype="multipart/form-data">

	<div class="layui-form-item"><label class="layui-form-label">品牌分类</label><div class="layui-inline" style="width:180px;"><select lay-verify="required" name="menus[]" ><option value="">请选择..</option>
	{foreach($menus['type'] as $v)}
	<option value="3" {if($v.id == $data.menus)}selected{/if}> {$v.name2}</option>{/foreach}
	</select></div><div class='layui-inline'><div class='layui-form-mid layui-word-aux'>请选择品牌所属类型</div></div></div><div class="layui-form-item">
    <label class="layui-form-label">品牌归属</label>
    <div class="layui-input-inline" style="width:180px;">
	<select name="company" lay-verify="required">
	<option value="">请选择..</option>
		 <option value="xxx" >xxx</option>
		</select>    </div>
	<div class="layui-form-mid layui-word-aux">请选择品牌归属的公司或个人（需通过认证，若选择归属为个人，前台显示会隐藏部分姓名）</div>   
</div>

<div class="layui-form-item">
    <label class="layui-form-label">品牌名称</label>
	    <div class="layui-input-inline" style="width:180px;">
		<input name="tit" class="layui-input" value="" maxlength="10"  lay-verify="pname" size="30" type="text" />
    </div>
	<div class="layui-form-mid layui-word-aux">您的品牌名称，2~10个字符（发布成功后不可修改）</div> 
	</div>



<div class="layui-form-item">
    <label class="layui-form-label">品牌主页</label>
    <div class="layui-input-inline" style="width:180px;">
		<input name="website" class="layui-input" value="" maxlength="50" size="10" type="text" />
    </div>
	<div class="layui-form-mid layui-word-aux">选填，品牌的官方地址，含http(s)://</div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">品牌URL</label>
		<div class="layui-form-mid layui-word-aux" style='margin-right:2px'>{:sysconf('site_domain')}/b/</div> 

    <div class="layui-input-inline" style="width:134px;">
		<input name="url" class="layui-input" value="" maxlength="15"  lay-verify="url"  type="text" />
    </div>
	<div class="layui-form-mid layui-word-aux">品牌在{:sysconf('site_name')}的访问地址，3~15位，字母 a-z 、数字 0-9 和下划线 _ 组成（发布成功后不可修改）</div> 
	</div>
<div class="layui-form-item">
    <label class="layui-form-label">品牌简介</label>
	<div class="layui-input-inline" style="width:206px;">
		<textarea name="desc"  class="layui-textarea checkLen" lay-verify="desc" maxlength="80"  d_len="40" ></textarea>
	</div>
	<div class="layui-form-mid layui-word-aux">您还可以输入 <b id="check_count">0</b> 个字<br>用20~40个字符简单介绍下品牌（用于品牌列表显示）</div></div>

<div class="layui-form-item">
    <label class="layui-form-label">品牌LOGO</label>
    <div class="layui-input-block">
	<div class="layui-box layui-upload-button"><input type="file" name="file"  lay-verify="required" id="picinp" class="layui-upload-file" accept="image/png,image/jpeg,image/gif" onchange="checkfile(this,'pic')"><span class="layui-upload-icon"><i class="layui-icon"></i>选择图片</span></div> <div class="layui-inline"> <div class="layui-form-mid layui-word-aux " style="color:red"></div></div>
	<br>
<div class="div_preview" pixel_data='0' size_data="3145728"  style='width:200px;height:200px;' id="pic">
<div class="preview_tips"><span><strong	 style='font-size:15px;'>品牌LOGO(<font style='color:red;'>必传</font>)</strong> <p>清晰美观的LOGO会提升品牌形象</p><p>尺寸200x200</p></span></div>
<img src=""></div>
</div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">详细介绍</label>
    <div class="layui-input-block form-textarea-box" style='width:650px'><textarea name="txt" lay-verify="required"  id='content'></textarea></div>
</div>


<div class="layui-form-item">
    <label class="layui-form-label">介绍大图</label>
    <div class="layui-input-block" style='width:650px'>
	<div class="upload-box" style='margin:0'>
	<div class="container">
				<div class="statusBar">
				<div class="info"><b>1.</b>限传9张大图（含已传），尺寸不限，单图大小限3M，格式 jpg/gif/png<br><b>2.</b>演图可插入上方（详细介绍），未插入将按排序依次显示在详细介绍之后</div>
					<div class="btns">
					<a id="browse">选择图片</a>
					</div>
				</div>
<table  class="fu_list"   id='pluing' style="display:none;" >
            <thead>
              <tr>
                <td width="64%">待传队列（<u>0</u>）</td>
				<td width="22%" align="center"></td>
                <td width="14%" align="center">操作</td>
              </tr>
            </thead>
            <tbody id="FileListing">
            </tbody>
          </table>
				<div class="filelist">
				</div>
		
		
	</div>
</div>
</div>
</div>




	<div class="layui-form-item" style='padding-bottom:15px;'>
		<label class="layui-form-label"></label>
		<div class="layui-input-inline"><input type="submit" lay-submit='' class="layui-btn lay-submit" value="确认提交" /></div>
	</div>

  <input type="hidden" name="bh" value="{$bh}">
  <input type="hidden" name="action" value="{$action}">
  <input type="hidden" name="passkey" value="{:passkey()}">
  <input type="hidden" name="psort" id='psort' >
</form>

<script type="text/javascript">
function banKey(text){if(!text)return[];var str='{$bankey}',strs=decodeURIComponent(str).split(','),list=[];strs.forEach(v=>{var v=v.toLowerCase();if(text.toLowerCase().indexOf(v)>-1&&$.inArray(v,list)<0)list.push(v)});return list}
var editor = new wangEditor('content');
editor.onchange = function() {
	editor.$txt.find("img").remove()
};
editor.create();
layer_psort = function() {
	psort = '';
	$(".filelist div").each(function(i) {
		$(this).find('.icon').html(i + 1);
		psort += $(this).find('.fdel').attr('id') + ","
	});
	$('#psort').val(psort)
};
$('.filelist .fleft,.fright').live('click', function() {
	var $v = 0;
	if ($('.filelist div').length < 2) {
		layer.alert("亲，就我1个，您想移哪去？", {
			icon: 0
		});
		return false
	}
	$(".filelist .file-panel").css({
		"height": "0"
	});
	$this = $(this).closest('div');
	$athis = $this.prev();
	$bthis = $athis;
	if ($(this).attr('class') == "fright") {
		$athis = $this;
		$this = $this.next();
		$bthis = $this
	}
	if ($bthis.length <= 0) {
		$this = $(".filelist div:first");
		$athis = $(".filelist div:last");
		$v = 1
	}
	$this.animate({
		top: $athis.position().top - $this.position().top,
		left: $athis.position().left - $this.position().left
	}, "300", function() {
		if ($v == 1) {
			$athis.after($this);
			if ($('.filelist div').length > 2) {
				$(".filelist div:first").before($athis)
			}
		} else {
			$athis.before($this)
		}
	});
	$athis.animate({
		top: $this.position().top - $athis.position().top,
		left: $this.position().left - $athis.position().left
	}, "300", function() {
		$('.filelist div').css({
			"left": "0",
			"top": "0"
		});
		layer_psort()
	})
});
$(".filelist div").live('mouseenter', function() {
	$(this).find('.file-panel').stop().animate({
		height: 30
	})
});
$(".filelist div").live('mouseleave', function() {
	$(this).find('.file-panel').stop().animate({
		height: 0
	})
});
$('.file-panel a').live({
	mouseenter: function() {
		$(this).find("span").addClass("cur")
	},
	mouseleave: function() {
		$(this).find("span").removeClass("cur")
	}
});
var maxnum = 9,
	stop = 0;
$(".filelist .fdel").live('click', function() {
	var $this = $(this);
	$.ajax({
		type: "POST",
		url: "/upload/",
		async: true,
		data: "action=del&p={$data.bh}&object=" + $this.attr('id') + "&type=brand",
		success: function(is) {
			var arr = is.split('|');
			var datas = $.trim(arr[0]);
			if (datas == 0) {
				layer.login('再删除', $this.attr('id'))
			} else if (datas == 1) {
				$this.closest('div').remove();
				layer_psort();
				if ($('.filelist div').length <= 0) {
					$('.filelist').hide();
					return false
				}
			} else {
				layer.alert(arr[1], {
					icon: datas
				})
			}
		},
		error: function() {
			layer.msg('网络异常，请重试');
			return false
		}
	})
});
var uploader = new plupload.Uploader({
	runtimes: 'html5,flash,silverlight,html4',
	browse_button: 'browse',
	url: "/upload/",
	resize: {
		width: 900
	},
	max_retries: 1,
	flash_swf_url: '/Check/Moxie.swf',
	silverlight_xap_url: '/Check/Moxie.xap',
	filters: {
		prevent_duplicates: true,
		max_file_size: '3mb',
		mime_types: [{
			title: "图片文件",
			extensions: "jpg,png,gif"
		}]
	},
	multi_selection: true
});
uploader.init();
uploader.bind('FilesAdded', function(uploader, files) {
	var newnum = maxnum - parseInt($('.filelist div').length + $('#FileListing tr').length),
		flen = files.length,
		fhtml, vhtml = '',
		ehtml = '';
	if (flen > newnum) {
		layer.alert("<strong>演示图最多能上传" + maxnum + "张（含已传）</strong>", {
			icon: 2
		});
		uploader.splice(newnum, 10000)
	}
	for (var i = 0; i <= flen; i++) {
		if (i == flen) {
			if (ehtml != '') {
				layer.alert("<strong>以下图片已传过了，不要重复上传</strong><br>" + ehtml, {
					icon: 0
				})
			}
			if (uploader.files.length > 0) {
				$('#pluing').show();
				$(fhtml).appendTo('#FileListing');
				$('#pluing u').html(uploader.files.length); 			}
			return false
		}
		if (i >= newnum) {
			continue
		}
		var fname = files[i].name,
			fid = files[i].id,
			fSuffix = fname.substr(fname.indexOf(".")),
			f5name = $.md5(files[i].size + files[i].lastModifiedDate + files[i].type) + fSuffix;
		vhtml = '<tr id="file-' + fid + '"><td>' + fname + '</td><td></td><td align="center"><a onclick=deling("' + fid + '")>取消</a></td></tr>';
		$(".filelist .fdel").each(function() {
			if ($(this).attr('id') == f5name) {
				vhtml = '';
				uploader.removeFile(fid);
				ehtml += "【" + fname + "】<br>";
				return false
			}
		});
		fhtml = fhtml + vhtml
	}
});
uploader.bind("BeforeUpload", function(uploader, file) {
	uploader.setOption("multipart_params", {
		lastDate: file.lastModifiedDate,
		osize: file.size,
		number: '{$data.bh}',
		action: 'add',
		type: 'brand',
		maxnum: maxnum
	})
});  uploader.bind("UploadProgress", function(uploader, file) {
		$('#progress-in').width(uploader.total.percent + "%");
		$("#file-" + file.id + " td:eq(2)").html("<b>" + file.percent + "%</b>")
	});
	uploader.bind("FileUploaded", function(uploader, file, info) {
		$('#progress-uploaded').html(uploader.total.uploaded);
		var data = $.parseJSON(info.response);
		if (data.state != 0) {
			$fh = $('#progress ul');
			$fh.show();
			$('<p><span>' + file.name + '</span><br><b>' + data.state + ' >> 继续执行…</b></p>').appendTo($fh);
			stop = 4000
		}
	});
	uploader.bind("UploadComplete", function(uploader) {
		setTimeout("$(\"form\").submit()", stop)
	});  uploader.bind("Error", function(uploader, err) {
	if (err.message == 'HTTP Error.') {
		fid = err.file.id;
		$("#file-" + fid + " td:eq(1)").html("<font color=red>系统出错，代码" + err.code + "</font>");
		$("#file-" + fid + " td:eq(2)").html('<a onclick=deling("' + fid + '")>删除</a>');
		return false
	}
	layer.alert("<strong>" + err.message + "</strong>", {
		icon: 5
	})
});
layui.use('form', function() {
	var form = layui.form();
	form.verify({
		pname: function(value) {
			if (!/^[\u4E00-\u9FA5A-Za-z0-9]+$/.test(value)) return '品牌名称格式不符合要求！';
			if (value.length < 2 || value.length > 10) return '品牌名称长度范围不符合要求！'
		},
		url: function(value) {
			if (!/^[a-zA-Z0-9_]{3,15}$/.test(value)) return '品牌URL格式不符合要求！'
		},
		desc: function(value) {
			if (!/^.{20,40}$/.test(value)) return '品牌简介长度范围不符合要求！'
		}
	});
	form.on('submit', function(data) {
		var isOK=true,BanKeyTrue=false;
		$('.demandtips').remove();editor.$txt.html(editor.$txt.html().replace(/<\/?(cite)[^>]*>/gi,''));$.each(['tit','cdes','txt','azbz'],function(key,name){var input=$('[name='+name+']'),Res=banKey(input.val());if(Res.length>0){var div=input.closest(".layui-form-item"),tips='【'+div.find(".layui-form-label").html().replace(/[^0-9\u4e00-\u9fa5]/g,'')+'】含有违禁关键词：<font class="red">'+Res.join('、')+'</font>',html='<div class="demandtips" style="margin:15px 20px 0 110px;padding:8px 10px 5px 10px"><a class="close" onclick="$(this).parent().fadeOut(\'slow\');" title="关闭提示">X</a><p class="title"><i class="icons" style="margin-top:-12px"></i><b style="font-size:14px;">'+tips+'</b></p></div>';div.prev().attr('class')=='demandtips'?div.prev().find('b').html(tips):div.before(html);if(name=='txt'){Res.forEach(v=>{editor.$txt.html(editor.$txt.html().replace(new RegExp(v,"gm"),'<cite style="background:red;color:#fff;">'+v.trim()+'</cite>'))})}isOK=false;BanKeyTrue=true}});if(BanKeyTrue)scTop(".demandtips:eq(0)",15);if(!isOK){return false}
		if (uploader.total.queued > 0) {
			progress();
			$('#progress-upload').html(uploader.total.queued);
			uploader.start();
			return false
		} else {
			progress(true);
			return true
		}
	})
});
</script>
</div>
{include file="bottom"}<script>
$(function(){ 
	$('.flow-step li[data=form]').addClass('on').siblings().removeClass('on');
});
</script>
</body>
</html>